#!/bin/bash

if [ $# -eq 0 ]; then
    echo "Error: 请传入日志文件路径"
    exit 1
fi

LOG_FILE=$1

# 初始化日志
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")

TEMP=$(cat /sys/class/thermal/thermal_zone0/temp | awk '{printf "%.2f°C\n", $1/1000}')
echo "开始时间: $TIMESTAMP" > "$LOG_FILE"
echo "初始温度: $TEMP" >> "$LOG_FILE"

# 持续记录（每10秒一次）
while true; do
    TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
    TEMP=$(cat /sys/class/thermal/thermal_zone0/temp | awk '{printf "%.2f°C\n", $1/1000}')
    echo "[$TIMESTAMP] 当前温度: $TEMP" >> "$LOG_FILE"
    sleep 10
done
